<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
	xmlns:exist="http://exist.sourceforge.net/NS/exist">
	<xsl:include href="../header.xsl"/>
	<xsl:include href="../footer.xsl"/>
	<xsl:include href="admin_menu.xsl"/>
	<xsl:param name="display_path">../</xsl:param>
	<xsl:param name="exist-url"/>
	<xsl:variable name="orbeon-url">
		<xsl:value-of select="document(concat($exist-url,  '/site_info.xml'))//orbeon_url"/>
	</xsl:variable>

	<xsl:template match="/">
		<html>
			<head>
				<title>
					<xsl:value-of
						select="document(concat($exist-url, '/site_info.xml'))/site_info/title"/>
					<xsl:text>: Manage Pages</xsl:text>
				</title>
				<link rel="stylesheet" type="text/css"
					href="http://yui.yahooapis.com/2.8.2r1/build/grids/grids-min.css"/>
				<link rel="stylesheet" type="text/css"
					href="http://yui.yahooapis.com/2.8.2r1/build/reset-fonts-grids/reset-fonts-grids.css"/>
				<link rel="stylesheet" type="text/css"
					href="http://yui.yahooapis.com/2.8.2r1/build/base/base-min.css"/>
				<link rel="stylesheet" type="text/css"
					href="http://yui.yahooapis.com/2.8.2r1/build/fonts/fonts-min.css"/>
				<!-- Core + Skin CSS -->
				<link rel="stylesheet" type="text/css"
					href="http://yui.yahooapis.com/2.8.2r1/build/menu/assets/skins/sam/menu.css"/>
				
				<link type="text/css" href="{$display_path}style.css" rel="stylesheet"/>
				<script type="text/javascript" language="javascript" src="{$display_path}javascript/jquery-1.3.2.min.js"/>
				<script type="text/javascript" language="javascript" src="{$display_path}javascript/show_delete_window.js"/>
			</head>
			<body class="yui-skin-sam">
				<div id="doc4" class="yui-t2">
					<xsl:call-template name="header"/>
					<div id="bd">
						<div id="yui-main">
							<div class="yui-b">
								<h2>Manage Pages</h2>
								<p>
									<a href="{$display_path}admin">&lt; Return</a>
								</p>
								<p>
									<a href="pages/create">Create New Page</a>
								</p>
								<xsl:if test="//page">
									<h3>List of Pages</h3>
									
									<table style="width:100%">
										<tr>
											<th style="width:50%">Title</th>
											<th style="width:20%">Short Title</th>
											<th style="width:10%">View</th>
											<th style="width:10%">Publish</th>
											<th style="width:10%">Delete</th>
										</tr>
										
										<xsl:apply-templates select="//page"/>
										
									</table>
									<div class="delete_window" style="display:none">
										<div class="trigger_container_header">
											<h3 style="margin-left:10px;"/>
											<div class="close">close</div>
										</div>
										<iframe src="" scrolling="no" frameborder="0"
											style="width:100%"/>
									</div>
								</xsl:if>
							</div>
						</div>
						<xsl:call-template name="admin_menu"/>
					</div>
					<xsl:call-template name="footer"/>
				</div>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="page">
		<xsl:variable name="class">
			<xsl:choose>
				<xsl:when test="position() mod 2 = 0">even-row</xsl:when>
				<xsl:otherwise>odd-row</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<tr>
			<td class="{$class}">
				<h3>
					<a href="pages/edit?id={@id}">
						<xsl:value-of select="title"/>
					</a>
				</h3>
			</td>
			<td class="{$class}">
				<xsl:value-of select="short-title"/>
			</td>
			<td class="{$class}" style="text-align:center">
				<a href="{$display_path}pages/{@stub}" target="_blank">html</a>
			</td>
			<td class="{$class}" style="text-align:center">


				<xsl:choose>
					<xsl:when test="public = '1'">
						<input type="checkbox" class="publish_checkbox" id="publish_{@id}"
							baseurl="{$orbeon-url}page/" title="{title}" checked="checked"/>
					</xsl:when>
					<xsl:otherwise>
						<input type="checkbox" class="publish_checkbox" id="publish_{@id}"
							baseurl="{$orbeon-url}page/" title="{title}"/>
					</xsl:otherwise>
				</xsl:choose>

			</td>
			<td class="{$class}" style="text-align:center">
				<a class="delete_button" id="delete_{@id}" title="{title}"
					baseurl="{$orbeon-url}page/">
					<img src="{$display_path}images/remove.gif"/>
				</a>
			</td>
		</tr>
	</xsl:template>

</xsl:stylesheet>
